package com.eling.elcms.travel.service.impl;


import com.eling.elcms.core.service.impl.GenericManagerImpl;
import com.eling.elcms.core.util.PropertyUtils;
import com.eling.elcms.travel.dao.ICustomerDao;
import com.eling.elcms.travel.model.Customer;
import com.eling.elcms.travel.model.view.QueryAllIntentionView;
import com.eling.elcms.travel.service.ICustomerManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CustomerManagerImpl extends GenericManagerImpl<Customer, Long> implements ICustomerManager {

	ICustomerDao customerDao;

	@Autowired
	public void setDao(ICustomerDao dao) {
		this.dao = dao;
		this.customerDao = dao;
	}

	@Override
	public List<Customer> queryAll(Customer cond) {
		List<Long> pkList = customerDao.queryAllPkCustomer(cond);
		
		List<Customer> returnList = new ArrayList<Customer>();
		if(!pkList.isEmpty()){
			Customer cus = new Customer();
			PropertyUtils.setProperty(cus, "pkCustomerIn", pkList);
			returnList = dao.query(cus);
		}
		return returnList;
	}

	@Override
	public List<QueryAllIntentionView> queryAllIntention(Customer cond) {
		
		
		return customerDao.queryAllIntention(cond);
	}

}
